//
//  AutoArchiveViewController.m
//  OCTest
//
//  Created by 韩艳锋 on 2018/4/27.
//  Copyright © 2018年 韩艳锋. All rights reserved.
//

#import "AutoArchiveViewController.h"
#import <objc/runtime.h>
#import <objc/message.h>
#import "Dog1.h"
@interface AutoArchiveViewController ()

@end

@implementation AutoArchiveViewController

- (void)viewDidLoad {
    [super viewDidLoad];

   
//    me1 = class_getInstanceMethod([NSObject class], NSSelectorFromString(@"initWithCoder:"));
//    me2 = class_getInstanceMethod([AutoArchiveViewController class], NSSelectorFromString(@"initHFWithCoder:"));
//    method_exchangeImplementations(me2, me1);
    
    Dog1 * dog = [[Dog1 alloc] init];
    dog.name = @"dogName";
    dog.age = @1;
    dog.agee = 1;
    
    NSString * str = [NSString stringWithFormat:@"%@%@",NSHomeDirectory(), @"/Documents/data.plist"];
    [NSKeyedArchiver archiveRootObject:dog toFile:str];
    
}



//- (instancetype)initHFWithCoder:(NSCoder *)aDecoder {
//    self = [self initHFWithCoder:aDecoder];
//    u_int count;
//    objc_property_t * properties = class_copyPropertyList([self class], &count);
//    for (int i = 0; i < count; i++) {
//        const char * properttName = property_getName(properties[i]);
//        NSString * name = [NSString stringWithCString:properttName encoding:NSUTF8StringEncoding];
//        NSString * value = [aDecoder decodeObjectForKey:name];
//        SEL sel = NSSelectorFromString([NSString stringWithFormat:@"set"]);
//        objc_msgSend(self, sel);
//    }
//    return self;
//}
@end
